<template>
  <view class="content">
    <image
      src="@/static/image/mineBlack.png"
      style="width: 100%; height: 446rpx; position: absolute"
    />
    <!-- 自定义导航栏 -->
    <!-- <view class="navBarBox">
      <view
        class="statusBar"
        :style="{ paddingTop: statusBarHeight + 'px' }"
      ></view>
      <view class="navBar">
        <view>我的</view>
      </view>
    </view> -->

    <!-- #ifdef MP -->
    <hx-navbar
      ref="hxnb"
      :config="{
        back: false,
        title: '我的',
        fontSize: '15px',
        backgroundColor: [0, '#00000'],
      }"
    />
    <!-- #endif -->
    <view class="header">
      <image
        src="@/static/image/moren.png"
        style="width: 80rpx; height: 80rpx"
      />
      <view class="head-info">
        <text style="font-size: 14px; font-weight: 600">{{
          userInfo ? userInfo.userName : "未登录"
        }}</text>
        <text style="color: #7b7b7b; font-size: 13px">{{
          userInfo ? (userInfo.phone == null ? "未设置" : userInfo.phone) : ""
        }}</text>
      </view>
    </view>
    <view class="project-info" style="z-index: 2; margin-top: 40rpx">
      <view class="info-top">
        <view style="font-size: 14px; font-weight: 600; margin-left: 14rpx"
          >项目信息</view
        >
      </view>
      <view
        style="height: 150rpx; width: 100%; margin-top: 20rpx; display: flex"
      >
        <view
          style="
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
          "
          @click="goProjectInfo(0)"
        >
          <image
            src="@/static/image/mine/baoming.png"
            style="width: 50rpx; height: 50rpx"
          />
          <text style="margin-top: 22rpx; font-size: 13px; font-weight: 600"
            >报名项目</text
          >
        </view>
        <view
          style="
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
          "
          @click="goProjectInfo(1)"
        >
          <image
            src="@/static/image/mine/jingjia.png"
            style="width: 50rpx; height: 50rpx"
          />
          <text style="margin-top: 22rpx; font-size: 13px; font-weight: 600"
            >竞价项目</text
          >
        </view>
        <view
          style="
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
          "
          @click="goProjectInfo(2)"
        >
          <image
            src="@/static/image/mine/zhongbiao.png"
            style="width: 50rpx; height: 50rpx"
          />
          <text style="margin-top: 22rpx; font-size: 13px; font-weight: 600"
            >中标项目</text
          >
        </view>
        <!-- <view
          style="
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
          "
        >
          <image
            src="@/static/image/mine/fabu.png"
            style="width: 50rpx; height: 50rpx"
          />
          <text style="margin-top: 22rpx; font-size: 13px; font-weight: 600"
            >发布项目</text
          >
        </view> -->
      </view>
    </view>
    <view class="project-info" style="margin-top: 40rpx">
      <view class="info-top">
        <view style="font-size: 14px; font-weight: 600; margin-left: 14rpx"
          >系统设置</view
        >
      </view>
      <view
        style="
          width: 100%;
          height: 332rpx;
          background-color: white;
          border-radius: 20rpx;
          box-shadow: #f0f0f052 0px 0px 10px 5px;
          margin-top: 40rpx;
          display: flex;
          flex-direction: column;
          align-items: center;
        "
      >
        <view
          style="
            flex: 1;
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 616rpx;
          "
          @click="updatePassword"
        >
          <view style="width: 40%; display: flex; align-items: center">
            <image
              src="@/static/image/mine/xiugai.png"
              style="width: 38rpx; height: 42rpx"
            />
            <text style="font-size: 13px; font-weight: 600; margin-left: 35rpx"
              >修改密码</text
            >
          </view>
          <uni-icons type="forward" size="22" color="#242424"></uni-icons>
        </view>
        <view style="width: 616rpx; border-bottom: 1px solid #f8f8f8ff"></view>
        <view
          style="
            flex: 1;
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 616rpx;
          "
          @click="feedback"
        >
          <view style="width: 40%; display: flex; align-items: center">
            <image
              src="@/static/image/mine/fankui.png"
              style="width: 38rpx; height: 38rpx"
            />
            <text style="font-size: 13px; font-weight: 600; margin-left: 35rpx"
              >意见反馈</text
            >
          </view>
          <uni-icons type="forward" size="22" color="#242424"></uni-icons>
        </view>
        <view style="width: 616rpx; border-bottom: 1px solid #f8f8f8ff"></view>
        <view
          style="
            flex: 1;
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 616rpx;
          "
          @click="goLogin"
        >
          <view style="width: 40%; display: flex; align-items: center">
            <image
              src="@/static/image/mine/tuichu.png"
              style="width: 38rpx; height: 38rpx"
            />
            <text
              style="font-size: 13px; font-weight: 600; margin-left: 35rpx"
              >{{ userInfo ? "退出登录" : "点击登录" }}</text
            >
          </view>
          <uni-icons type="forward" size="22" color="#242424"></uni-icons>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { mineProject } from "@/utils/api.js";
export default {
  data() {
    return {
      statusBarHeight: uni.getSystemInfoSync()["statusBarHeight"],
      userInfo: {},
    };
  },
  onLoad() {},
  onShow() {
    this.userInfo = uni.getStorageSync("userInfo");
  },
  methods: {
    async updatePassword() {
      let res = await mineProject.getGrEnrollSupplyProject({
        pageNum: 0,
        pageSize: 10,
      });
      if (res.code == "401001" || res.code == "401002") {
        uni.showModal({
          title: "登录状态过期或未登录",
          content: "是否立即登录",
          cancelText: "取消", // 取消按钮的文字
          confirmText: "确认", // 确认按钮的文字
          showCancel: true, // 是否显示取消按钮，默认为 true
          success: (res) => {
            if (res.confirm) {
              uni.navigateTo({
                url: "/pages/login/login",
              }); //点击确定之后执行的代码
            } else {
              console.log("cancel"); //点击取消之后执行的代码
            }
          },
        });
      } else {
        uni.navigateTo({
          url: "/pages/updatePassword/updatePassword",
        });
      }
    },
    async feedback() {
      let res = await mineProject.getGrEnrollSupplyProject({
        pageNum: 0,
        pageSize: 10,
      });
      if (res.code == "401001" || res.code == "401002") {
        uni.showModal({
          title: "登录状态过期或未登录",
          content: "是否立即登录",
          cancelText: "取消", // 取消按钮的文字
          confirmText: "确认", // 确认按钮的文字
          showCancel: true, // 是否显示取消按钮，默认为 true
          success: (res) => {
            if (res.confirm) {
              uni.navigateTo({
                url: "/pages/login/login",
              }); //点击确定之后执行的代码
            } else {
              console.log("cancel"); //点击取消之后执行的代码
            }
          },
        });
      } else {
        uni.navigateTo({
          url: "/pages/feedback/feedback",
        });
      }
    },
    goLogin() {
      uni.navigateTo({
        url: "/pages/login/login",
      });
    },
    async goProjectInfo(e) {
      let res = await mineProject.getGrEnrollSupplyProject({
        pageNum: 0,
        pageSize: 10,
      });
      if (res.code == "401001" || res.code == "401002") {
        uni.showModal({
          title: "登录状态过期或未登录",
          content: "是否立即登录",
          cancelText: "取消", // 取消按钮的文字
          confirmText: "确认", // 确认按钮的文字
          showCancel: true, // 是否显示取消按钮，默认为 true
          success: (res) => {
            if (res.confirm) {
              uni.navigateTo({
                url: "/pages/login/login",
              }); //点击确定之后执行的代码
            } else {
              console.log("cancel"); //点击取消之后执行的代码
            }
          },
        });
      } else {
        uni.navigateTo({
          url: "/pages/mineProjectInfo/mineProjectInfo?page=" + e,
        });
      }
    },
  },
};
</script>

<style scoped lang="less">
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  .header {
    margin-bottom: 20rpx;
    z-index: 2;
    display: flex;
    align-items: center;
    width: 80%;
    .head-info {
      margin-left: 20rpx;
      display: flex;
      height: 100rpx;
      justify-content: space-around;
      flex-direction: column;
    }
  }
  .project-info {
    width: 93%;
    .info-top {
      display: flex;
      justify-content: space-between;
    }
    .info-content {
      width: 100%;
      border: 1px solid rgb(153, 153, 153);
      margin-top: 20rpx;
      height: 80rpx;
      border-radius: 10rpx;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
  .navBarBox {
    width: 100%;
    z-index: 2;
    .navBar {
      height: 88rpx;
      display: flex;
      justify-content: center;
      line-height: 88rpx;
      font-size: 15px;
    }
  }
}
</style>
